<!doctype html>
<html class="no-js" manifest="__PUBLIC__/home/manifest/test.manifest">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <title>修改密码</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="绵阳中学英才学校" />
    <!-- Tile icon for Win8 (144x144 + tile color) -->
    <meta name="msapplication-TileColor" content="#0e90d2">
    <link rel="stylesheet" href="__PUBLIC__/home/css/amazeui.min.css">
    <link rel="stylesheet" href="__PUBLIC__/home/css/login.css">
    <link rel="stylesheet" href="__PUBLIC__/home/css/reg.css">
</head>

<body>
    <!-- 头部 -->
    <header data-am-widget="header" class="am-header am-header-default">
      <div class="am-header-left am-header-nav">
        <a href="javascript:history.go(-1);" class="am-header-left1">
          <img src="__PUBLIC__/home/images/back.png" alt="">
        </a>
      </div>
      <div class="am-header-right am-header-nav">
        <a href="{:U('Index/index')}" class="am-header-right1">
          <img src="__PUBLIC__/home/images/home.png" alt="">
        </a>
      </div>
    </header>

    <!-- 中间 -->
    <div class="content">
      <div class="am-g">
        <div class="am-u-sm-11 am-u-sm-centered">
          <img src="__PUBLIC__/home/images/login_logo.png" alt="">
        </div>
      </div>

        <div class="am-g">
          <div class="am-u-sm-11 am-u-sm-centered">
            <div  class="am-header-left reg_name">新&nbsp;&nbsp;密&nbsp;&nbsp;码:</div>
            <input type="password" name="password" class="name_text am-header-right reg_text">
          </div>
        </div>
        <div class="am-g">
          <div class="am-u-sm-11 am-u-sm-centered">
            <div  class="am-header-left reg_name">确认密码:</div>
            <input type="password" id="second_p"  class="name_text am-header-right reg_text">
          </div>
        </div>

        <div class="am-g reg_login">
          <div class="am-u-sm-11 am-u-sm-centered login_login">
            <button  id="btn" class="am-btn am-btn-success am-u-sm-7">修改</button>
          </div>
        </div>
    </div>

    <script src="__PUBLIC__/home/js/jquery.min.js"></script>
    <script src="__PUBLIC__/home/js/amazeui.min.js"></script>
    <script> 
      //表单验证
      function check_form(){
        var reg_password = /^[a-zA-Z0-9]{6,20}$/;//密码验证
       
        //验证密码
        if(!reg_password.test($("input[name=password]").val())){
          alert('密码由6到20位数字组成');
          return false;
        }
  
        //判断两次密码是否相等
        if($("input[name=password]").val() != $("#second_p").val()){
          alert('两次密码不同');
          return false;
        }
        return true;
      }
      $('#btn').click(function(){
	   		if(check_form()){
	    		var psw = $("input[name=password]").val();
	   			$.ajax({
	    			type:"POST",
	    			url:"{:U('Login/update_password')}",
	    			data:{'password':psw},
	    			success:function(data){
	    				if(data==1){
	    					alert('修改成功');
	    					window.location.href = "{:U('User/user_center')}";
	    				}else{
	    					alert('修改失败');
	    				}
	    			}
	    		});
	   		}
  	});
    </script>
</body>

</html>
